Page({
  data:{
    passport: {}
  },
  onLoad({id, encryptedData}){
this.getPassport(id)
this.getPassportShare(encryptedData)
  },
 async getPassport(id){
  if (!id) return
const {code,data:passport}=await wx.http.get('/visitor/'+id)
if(code!==10000)return wx.utils.toast()
this.setData({passport})
 },
 async getPassportShare(encryptedData){
if(!encryptedData) return
const{code,data:passport}=await wx.http.get('/visitor/share/'+encryptedData)
if(code!==10000)return wx.utils.toast()
this.setData({passport})
 },
  onShareAppMessage() {
    const { encryptedData } = this.data.passport
    return {
      title: '查看通行证',
      path: '/visitor_pkg/pages/passport/index?encryptedData='+encryptedData,
      imageUrl: 'https://enjoy-plus.oss-cn-beijing.aliyuncs.com/images/share_poster.png',
    }
  },
  saveimages(){
try{
const {path}=  wx.getImageInfo({
    src: 'this.data.passport.url,',
  })
  wx.saveImageToPhotosAlbum({
    filePath:path
  })
}catch(err){
wx.utils.toast("保存图片失败")
}
  }
})
